﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Mailing.aspx.cs" Inherits="ankietyzacja.Mailing" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
Historia korespondencji
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>
    Historia korespondencji
</h2>

    
    <asp:GridView ID="EmailsGridView" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="EMAIL_ID" DataSourceID="EmailsSqlDataSource" Width="100%" 
        AllowPaging="True" AllowSorting="True" GridLines="None" Height="300px"  
        ShowFooter="True" onrowdatabound="EmailsGridView_RowDataBound" 
        onrowdeleting="EmailsGridView_RowDeleting">
        <Columns>
            <asp:TemplateField HeaderText="Temat e-maila" SortExpression="TEMAT">
                <ItemTemplate>
                    <asp:HyperLink CssClass="commandLink" ID="TematHyperLink" runat="server" Text='<%# Bind("TEMAT") %>' ToolTip ='<%# Bind("TRESC") %>'  NavigateUrl='<%# Eval("EMAIL_ID", "~/Email.aspx?email_id={0}") %>' />
                </ItemTemplate>
                <ItemStyle Width="50%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Data utworzenia" SortExpression="DATAUTWORZENIA">
                <ItemTemplate>
                    <asp:Label ID="DataUtworzeniaLabel" runat="server" Text='<%# Bind("DATAUTWORZENIA") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="20%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Data wysłania" SortExpression="DATAWYSLANIA">
                <ItemTemplate>
                    <asp:Label ID="DataWyslaniaLabel" runat="server" Text='<%# Bind("DATAWYSLANIA") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="20%" />
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="DeleteLinkButton" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Usuń"></asp:LinkButton>
                </ItemTemplate>
                <ControlStyle CssClass="commandLink" />
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
        </Columns>
        <FooterStyle Height="100%" />
        <PagerStyle HorizontalAlign="Center" />
    </asp:GridView>
    <asp:SqlDataSource ID="EmailsSqlDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ankietyzacjaConnectionString %>" 
        DeleteCommand="DELETE FROM [EMAIL] WHERE [EMAIL_ID] = @EMAIL_ID" 
        SelectCommand="SELECT * FROM [EMAIL] ORDER BY [DATAWYSLANIA] DESC, [DATAUTWORZENIA] DESC" >
        <DeleteParameters>
            <asp:Parameter Name="EMAIL_ID" Type="Int32" />
        </DeleteParameters>
    </asp:SqlDataSource>
    <asp:Button ID="NewEmailButton" runat="server" Text="Nowy e-mail" 
        onclick="NewEmailButton_Click" />
</asp:Content>
